﻿using System;
using System.Collections.Generic;

namespace CostomGameServer
{
	class Program
	{
		////没啥卵用但是看着好高级
		//Dictionary<string, Action> actions = new Dictionary<string, Action>{
		//	{"log",()=>Console.WriteLine(DateTime.Now) },
		//};

		static void Main(string[ ] args) {
			if (args.Length > 0 && args[ 0 ] == "fuck") {
				Console.WriteLine( "who fucked me???" );
			}

			UdpManager.Start( );

			ServerTick.Start( );


			//Main Loop
			while (true) {
				string[ ] input = Console.ReadLine( ).Split( ' ' );
				switch (input[ 0 ]) {
					case "log": Console.WriteLine( DateTime.Now ); break;
					case "echo": {
							for (int i = 1; i < input.Length; i++) {
								Console.WriteLine( input[ i ] );
							}
						}
						break;
					case "start": {
							if (input.Length == 1)
								Console.WriteLine( "Wrong Input." );
							switch (input[ 1 ]) {
								case "tick": ServerTick.Start( ); break;
								case "udp": UdpManager.Start( ); break;
							}
							break;
						}
					case "exit": ServerTick.Stop( ); return;
					default: {
							Console.Beep( );
							int vert = Console.CursorTop - 1;
							Console.SetCursorPosition( 0, vert );
							Console.Write( new string( ' ', Console.WindowWidth ) );
							Console.WriteLine( "bad input, enter again;" );
							Console.SetCursorPosition( 0, vert );
						}
						break;
				}
			}
		}
	}
}